package com.byb.server.service.mapper;

import com.byb.server.domain.*;
import com.byb.server.service.dto.AchievementDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Achievement and its DTO AchievementDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class,})
public interface AchievementMapper extends EntityMapper <AchievementDTO, Achievement> {

    @Mapping(source = "product.id", target = "productId")
    AchievementDTO toDto(Achievement achievement);

    @Mapping(source = "productId", target = "product")
    Achievement toEntity(AchievementDTO achievementDTO);
    default Achievement fromId(Long id) {
        if (id == null) {
            return null;
        }
        Achievement achievement = new Achievement();
        achievement.setId(id);
        return achievement;
    }
}
